package com.wc.alorithm_blue_bridge._DFS.Q3817;

import java.util.*;
/**
 * @Author congege
 * @Description
 * @Date Created in 2023/11/29-10:42
 */
public class Main2 {
    static int n, m;
    static char[][] map;
    static boolean[][][] vis;
    static int startX, startY;
    static int endX, endY;
    static int[][] positions = new int[][]{{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());
        m = Integer.parseInt(sc.next());
        startX = Integer.parseInt(sc.next()) - 1;
        startY = Integer.parseInt(sc.next()) - 1;
        int key = 1;
        endX = Integer.parseInt(sc.next()) - 1;
        endY = Integer.parseInt(sc.next()) - 1;
        map = new char[n][m];
        vis = new boolean[n][m][key + 1];
        for (int i = 0; i < n; i++) {
            map[i] = sc.next().toCharArray();
        }
        vis[startX][startY][0] = true;
        vis[startX][startY][1] = true;
        boolean res = dfs(startX, startY, 1);
        if (res) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static boolean dfs(int x, int y, int key) {
        if (x == endX && y == endY) {
            return true;
        }
        int nextX, nextY;
        boolean res = false;
        for (int[] position : positions) {
            nextX = x + position[0];
            nextY = y + position[1];
            if (!isBound(nextX, nextY) && !vis[nextX][nextY][key]) {
                vis[nextX][nextY][key] = true;
                if (map[nextX][nextY] == '.') {
                    res |= dfs(nextX, nextY, key);
                } else if (key > 0) {
                    res |= dfs(nextX, nextY, key - 1);
                }
            }
        }
        return res;
    }

    public static boolean isBound(int x, int y) {
        return x < 0 || x == n || y < 0 || y == m;
    }

}
